import type { RouteRecordRaw } from 'vue-router';
import { h } from 'vue';
import { RouterView } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    meta: {
      icon: 'lucide:settings',
      order: 100,
      title: '系统管理',
      permission: 'system:menu', // 系统管理菜单权限
    },
    name: 'System',
    path: '/system',
    children: [
      {
        name: 'DeptManagement',
        path: '/system/dept',
        component: () => import('#/views/system/dept/index.vue'),
        meta: {
          icon: 'lucide:building-2',
          title: '部门管理',
          permission: 'system:dept:view', // 部门管理权限
        },
      },
      {
        name: 'MenuManagement',
        path: '/system/menu',
        component: () => import('#/views/system/menu/index.vue'),
        meta: {
          icon: 'lucide:menu',
          title: '菜单管理',
          permission: 'system:menu:view', // 菜单管理权限
        },
      },
      {
        name: 'PermissionManagement',
        path: '/system/permission',
        component: () => import('#/views/system/permission/index.vue'),
        meta: {
          icon: 'lucide:shield-check',
          title: '权限管理',
          permission: 'system:permission:view', // 权限管理权限
        },
      },
      {
        name: 'RoleManagement',
        path: '/system/role',
        component: () => import('#/views/system/role/index.vue'),
        meta: {
          icon: 'lucide:users-round',
          title: '角色管理',
          permission: 'system:role:view', // 角色管理权限
        },
      },
      {
        name: 'UserManagement',
        path: '/system/user',
        component: () => import('#/views/system/user/index.vue'),
        meta: {
          icon: 'lucide:user',
          title: '用户管理',
          permission: 'system:user:view', // 用户管理权限
        },
      },
      {
        name: 'OAuth2ClientManagement',
        path: '/system/oauth2-client',
        component: () => import('#/views/system/oauth2-client/index.vue'),
        meta: {
          icon: 'lucide:key-round',
          title: 'OAuth2客户端',
          permission: 'system:oauth2:client:view', // OAuth2客户端管理权限
        },
      },
      {
        name: 'RateLimitManagement',
        path: '/system/rate-limit',
        component: () => h(RouterView),
        meta: {
          icon: 'lucide:shield-alert',
          title: '限流管理',
          permission: 'system:ratelimit:menu',
        },
        children: [
          {
            name: 'RateLimitConfig',
            path: '/system/rate-limit/config',
            component: () => import('#/views/system/rate-limit-config/index.vue'),
            meta: {
              icon: 'lucide:settings',
              title: '限流配置',
              permission: 'system:ratelimit:config',
            },
          },
          {
            name: 'RateLimitMonitor',
            path: '/system/rate-limit/monitor',
            component: () => import('#/views/system/rate-limit-monitor/index.vue'),
            meta: {
              icon: 'lucide:gauge',
              title: '限流监控',
              permission: 'system:ratelimit:monitor',
            },
          },
        ],
      },
    ],
  },
];

export default routes;
